<?php
    include_once('Configs/database.php');
    include_once('HocPhan.php');
    include_once('NganhHoc.php');
    include_once('DeCuongHPChiTiet.php');
    class ChuongTrinhDaoTao extends database{
        private $manganh;
        private $mahp;
        private $sotietbatbuoc;
        private $sotiettuchon;
        public function setMaNganh($manganh){
            $this->manganh = $manganh;
        }
        public function getMaNganh(){
            return $this->manganh;
        }
        
        public function setMaHP($mahp){
            $this->mahp = $mahp;
        }
        public function getMaHP(){
            return $this->mahp;
        }
        
        public function setSoTietBatBuoc($sotietbatbuoc){
            $this->sotietbatbuoc = $sotietbatbuoc;
        }
         public function getSoTietBatBuoc(){
            return $this->sotietbatbuoc;
        }
        
        public function setSoTietTuChon($sotiettuchon){
            $this->sotiettuchon = $sotiettuchon;
        }
        
        
       
        public function getSoTietTuChon(){
            return $this->sotiettuchon;
        }
        
        public function themChuongTrinhDaoTao(){                
            $query = "insert into ChuongTrinhDaoTao(manganh, mahp, sotietbatbuoc, sotiettuchon) ";
            $query .= "values ('".$this->getMaNganh()."','".$this->getMaHP()."',".$this->getSoTietBatBuoc().",".$this->getSoTietTuChon().")";
            
            $this->setQuery($query); 
                      
            return $this->executeQuery();
         }
        
         public function suaChuongTrinhDaoTao(){
            $query = "update ChuongTrinhDaoTao set sotietbatbuoc=".$this->getSoTietBatBuoc().", sotiettuchon=".$this->getSoTietTuChon()." ";
            
            $query .= " where manganh='".$this->getMaNganh()."' and mahp='".$this->getMaHP()."' ";
           
            $this->setQuery($query);
                                     
            return $this->executeQuery();
         }
         public function xoaChuongTrinhDaoTao(){
            $this->setQuery("delete from ChuongTrinhDaoTao where manganh='".$this->manganh."' and mahp='".$this->mahp."'");
            return $this->executeQuery();
         }
         public function dsHPTheoCTDT(){
            $this->setQuery("select a.mahp,tenhp,sotc,sotietbatbuoc,sotiettuchon from ChuongTrinhDaoTao a, HocPhan b, NganhHoc c where   a.manganh='".$this->getMaNganh()."' and a.mahp = b.mahp and a.manganh = c.manganh");
            return $this->fetchAll();
         }
    }
?>